package com.fg.cloud.manager.service.factory.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fg.cloud.common.PageUtils;
import com.fg.cloud.manager.entry.BaseEntity;
import com.fg.cloud.manager.entry.factory.WarehouseEntity;
import com.fg.cloud.manager.mapper.BaseMapper;
import com.fg.cloud.manager.mapper.factory.WarehouseMapper;
import com.fg.cloud.manager.service.BaseServiceImpl;
import com.fg.cloud.manager.service.factory.WarehouseService;

@Service
/**
 * 
 * @author liushengchao
 * @ClassName WareHouseServiceImpl
 * @Description: 仓库信息接口实现 
 * @date 2017年6月13日上午10:39:34
 *
 */
public class WarehouseServiceImpl extends BaseServiceImpl implements WarehouseService{
	
	@Autowired
	private WarehouseMapper whMapper;
	
	@Override
	protected <T extends BaseEntity> BaseMapper getBaseMapper() {
		return whMapper;
	}

	@Override
	@Transactional
	public Integer addWareHouse(WarehouseEntity wareHouseInfo) {
		Integer result = whMapper.insert(wareHouseInfo);
		return result;
	}

	@Override
	public List<WarehouseEntity> selectforPage(PageUtils<WarehouseEntity> pageinfo) {
		long total = whMapper.selectcount(pageinfo);
		pageinfo.setTotal(total);
		List<WarehouseEntity> list = new ArrayList<WarehouseEntity>();
		if(total>0){
			list = whMapper.selectforPage(pageinfo);
		}
		return list;
	}

	@Override
	@Transactional
	public int deletes(Map<String, Object> condition) {
		return whMapper.deletes(condition);
	}

	@Override
	public int findnum(WarehouseEntity wareHouseEntity) {
		return whMapper.findnum(wareHouseEntity);
	}

	@Override
	public List<WarehouseEntity> selectWarehouse(Long facId) {
		return whMapper.selectWarehouse(facId);
	}

}
